module alu_hier_bench;

	reg [15:0] A,B;
	reg [3:0] Op;
	wire [15:0] Out;
	wire Ofl,Zero;

	alu_hier U0 (
            .A(A),.B(B),.Op(Op),
            .Out(Out),.Ofl(Ofl),.Z(Zero)
            );

	integer k;
	initial
	begin
		Op = 4'b0000;
		A = 16'H0001;
		B = 16'H0020;
		#5	B = 16'Hffff;
		#5	A = 16'H1000;
			B = 16'H7FFF;
		#5	A = 16'H0080;
			B = 16'H00F0;
		
		#5	Op = 4'b0001;
		#5	A = 16'H1000;
			B = 16'H7FFF;

		#5	Op = 4'b0010;

		#5	Op = 4'b0011;
            A = 16'HFF0E;
            B = 16'H0004;

        #5  Op = 4'b0100;
        #5  Op = 4'b0101;
        #5  Op = 4'b0110;
        #5  Op = 4'b0111;
//  seq
        #5  Op = 4'b1100;
        #5  A = 16'H7000; B = 16'H9000;
        #5  A = 16'H2000; B = 16'H3000;
        #5  A = 16'H9000; B = 16'HF000;
//  slt
        #5  Op = 4'b1101;
        #5  A = 16'H7000; B = 16'H9000;
        #5  A = 16'H2000; B = 16'H3000;
        #5  A = 16'H9000; B = 16'HF000;
//  sle
        #5  Op = 4'b1110;
        #5  A = 16'H7000; B = 16'H9000;
        #5  A = 16'H2000; B = 16'H3000;
        #5  A = 16'H9000; B = 16'HF000;
//  sco
        #5  Op = 4'b1111;
        #5  A = 16'H7000; B = 16'H9000;
        #5  A = 16'H2000; B = 16'H3000;
        #5  A = 16'H9000; B = 16'HF000;

        #5  Op = 4'b1000;

		#10	$finish;
	end
	//	Output monitors
	always@(Op,A,B)
	begin
		#1;
		if (Op==4'b0000)
			$display("ADD: op1=%H op2=%H out=%H carry_out=%b zero=%b",
			A,B,Out,Ofl,Zero);

		if (Op==4'b0001)
			$display("SUB: op1=%H op2=%H out=%H carry_out=%b zero=%b",
			A,B,Out,Ofl,Zero);

		if (Op==4'b0010)
			$display("XOR: op1=%H op2=%H out=%H",
			A,B,Out);

		if (Op==4'b0011)
			$display("ANDN: op1=%H op2=%H out=%H",
			A,B,Out);

		if (Op==4'b0100)
			$display("rol: A=%b Cnt=%H Out=%b",A,B[3:0],Out);

		if (Op==4'b0101)
			$display("sll: A=%b Cnt=%H Out=%b",A,B[3:0],Out);
		if (Op==4'b0110)
			$display("ror: A=%b Cnt=%H Out=%b",A,B[3:0],Out);
		if (Op==4'b0111)
			$display("srl: A=%b Cnt=%H Out=%b",A,B[3:0],Out);

		if (Op==4'b1100)
			$display("seq: A=%H B=%H Out=%H",A,B,Out);
		if (Op==4'b1101)
			$display("slt: A=%H B=%H Out=%H",A,B,Out);
		if (Op==4'b1110)
			$display("sle: A=%H B=%H Out=%H",A,B,Out);
		if (Op==4'b1111)
			$display("sco: A=%H B=%H Out=%H",A,B,Out);

        if (Op[3:2]==2'b10)
            $display("btr: A=%b Out=%b",A,Out);
	end
endmodule
